home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
pdtimprk.zip
/
PDTIMPRK.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-09-02
|
22KB
|
532 lines
PAGE ,132 ; Corrected version, 9/2/87, DF
TITLE PDTIMPRK -- Public domain software by Dick Flanagan
;----------------------------------------------------------------------------+
; |
; Placed in the PUBLIC DOMAIN without warranty, guarantee, or |
; assumption of liability. All rights under copyright law are |
; unconditionally waived by the author. |
; |
; Written by Dick Flanagan, Ben Lomond, California, August 1987. |
; |
;----------------------------------------------------------------------------+
comment *
PPPPPP DDDDDD TTTTTTT III M M PPPPPP RRRRRR K K
P P D D T I MM MM P P R R K K
P P D D T I M M M M P P R R K K
PPPPPP D D T I M M M M PPPPPP RRRRRR KK
P D D T I M M M P R R K K
P D D T I M M P R R K K
P DDDDDD T III M M P R R K K
*
;----------------------------------------------------------------------------
;
; The purpose of this program is to automatically park fixed disk
; drive heads after a predetermined period of inactivity has passed.
;
; While there are several other programs available to accomplish
; this task, almost all are either copyrighted or have evolved from
; copyrighted material. Some of these programs are in the ignorent
; position of ostensibly being both copyrighted and in the public
; domain, or with restrictions on their "public domainness." Until
; their authors realize they can't have it both ways, these programs
; are assumed to be copyrighted.
;
; Program Syntax: PDTIMPRK <minutes>
;
; The <minutes> parameter is a single digit in the range of 1 to 9.
; It represents the number of minutes of inactivity that are to be
; allowed before the heads are to be automatically parked. Some
; people might like a slightly lower floor on this value, but
; (and since I can't imagine anyone realistically wanting a higher
; ceiling) I have retained this convention which is common in
; other programs.
;
; Only BIOS I/O functions are used, so the program should be
; usable across a broad spectrum of IBM-compatible computers.
;
; Theory of Operation:
;
; Every time a software interrupt 13 is issued it is inter-
; cepted by this program which checks if the request is for
; a fixed or floppy disk. If it is for a fixed disk, a
; count-down timer is reset and a flag is cleared to indicate
; that the disk heads are probably no longer parked.
;
; Every time a hardware timer interrupt 8 is detected it is
; also intercepted and, if the disks are not already parked
; and we are not in the process of parking them, the timer is
; decremented and checked to see if the interval has expired.
; If it has, a flag is set indicating that parking is in pro-
; gress, the disks are "seeked" to their innermost cylinder,
; the parking-in-progress flag is cleared, the heads-are-parked
; flag is set, and our task is done until the next interrupt
; 13 for one of the fixed disks sets our timer running again.
;
; The hardware timer interrupt 8 is used instead of the more
; conservative approach of using the bios-generated software
; interrupt 1C. The length of time required to park the disk
; heads requires that at least the timer interrupts be enabled
; during the parking, and the parking operation itself requires
; that disk interrupts be enabled. These effectivly dictate
; that we operate with all interrupts enabled.
;
; To enable interrupts from within the interrupt 1C logic would
; require that an EOI (End-Of-Interrupt) code be sent to the
; 8259A PIC (Programmable Interrupt Controller). The problem
; with this is that the Time Of Day interrupt handler that issued
; the interrupt 1C in the first place will issue another EOI to
; the 8259A as soon as we return. This second EOI can wreak
; havok with lower level interrupt handlers that may have been
; interrupted by the original timer interrupt.
;
; Instead, we intercept timer interrupt 8 and immediately pass
; it off to the bios Time Of Day routine. When we get control
; back, the EOI will already have been issued and we can proceed
; with a clear conscience.
;
; Author's Notes:
;
; Because I hate TSR's, I try to make them as small as possible.
; This one is about as small as I've seen with equivalent
; functionality.
;
; I have attempted to comment the code in such a way that its
; operation should be clearly evident and modifications or
; (horrors!) bug fixes should be easily implemented. I also
; hope the comments will help remove some of the mystery that
; surrounds assembly language in general and interrupt handlers
; in particular for many people.
;
; Because this program was a quick weekend project, its level of
; parameter checking and error recovery is minimal, but I feel it
; to be adequate for the task at hand. For example:
;
; Limitations:
;
; o Only the first non-blank, non-zero character on the command
; line is examined. If 20 is entered, the 2 will be accepted
; and the 0 will be ignored.
;
; o If one drive in a two-drive system is kept busy frequently
; enough so as not to be parked, the other drive, regardless
; of how idle it might be, will not be parked until the other
; one finally is (the old two-drive-one-timer problem).
;
; o No attempt is made to determine if the program has already
; been installed. Simple tests are easily confused and complex
; ones aren't worth the trouble for a program as small and
; benign as this.
;
; o No error recovery is attempted.
;
;----------------------------------------------------------------------------
CODE SEGMENT PARA
ASSUME CS:CODE, DS:NOTHING, ES:NOTHING, SS:NOTHING
ORG 0100H ; reserve space for psp
START: JMP INIT ; jump to initialization code
INT08VECT LABEL DWORD ; pre-existing interrupt 08 vector
INT08OFF DW 0 ;
INT08SEG DW 0 ;
INT13VECT LABEL DWORD ; pre-existing interrupt 13 vector
INT13OFF DW 0 ;
INT13SEG DW 0 ;
DRV0CYL DW 0 ; cylinder to park drive 0
DRV1CYL DW 0 ; cylinder to park drive 1
PARKED DB 0 ; non-zero = drives are parked
BUSY DB 0 ; non-zero = parking in progress
TIMER DW 0 ; decremented-to-zero timer counter
TICKS DW 0 ; timer reset value
;----------------------------------------------------------------------------
;
; all disk i/o via interrupt 13 is intercepted here. while all
; int 13 activity does not necessarily result in the disk drives
; becoming 'unparked,' the penalty in so assuming is reasonably
; small.
;
;----------------------------------------------------------------------------
INT13 PROC
;
; the less time spent with interrupts disabled the better, so
; reenable them right away
;
STI ; enable interrupts
;
; c